package top.dfghhj.chapter05;

public class JvmTest {

    /**
     *
     * 模拟每隔一段时间加载一些数据进行处理的BI系统
     *
     * JVM 参数：
     *
     * -XX:NewSize=104857600 -XX:MaxNewSize=104857600 -XX:InitialHeapSize=209715200 -XX:MaxHeapSize=209715200 -XX:SurvivorRatio=8  -XX:MaxTenuringThreshold=15 -XX:PretenureSizeThreshold=3145728 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:gc.log
     *
     * 配合 jstat 命令观察新生代对象增长和gc频率
     *
     * jstat -gc 440 1000 1000
     *
     * @param args
     * @throws InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(30 * 1000);
        while (true) {
            loadData();
        }
    }

    public static void loadData() throws InterruptedException {
        byte[] data = null;
        for (int i = 0; i < 50; i++) {
            data = new byte[100 * 1024];
        }
        data = null;

        Thread.sleep(1000);
    }

}
